package com.ezcoding.engine;

import com.ezcoding.model.Dingdan;
import com.ezcoding.model.DingdanDetail;

import java.util.List;

public class DindanCalculatorFactory {

    public static DingdanCalculator create(Dingdan dingdan, List<DingdanDetail> details) {
        DingdanCalculator calculator = null;

        switch (dingdan.getType()) {
            case Dingdan.DINGDAN_TYPE_SALE_OUT:
                calculator = new SaleOutCalculator(dingdan, details);
                break;
            case Dingdan.DINGDAN_TYPE_SALE_BACK:
                calculator = new SaleBackCalculator(dingdan, details);
                break;
            case Dingdan.DINGDAN_TYPE_PURCHASE_IN:
                calculator = new PurchaseInCalculator(dingdan, details);
                break;
            case Dingdan.DINGDAN_TYPE_PURCHASE_BACK:
                calculator = new PurchaseBackCalculator(dingdan, details);
                break;
            case Dingdan.DINGDAN_TYPE_PURCHASE_DINGDAN:
                calculator = new PurchaseDingdanCalculator(dingdan, details);
                break;
            default:
                break;
        }

        return calculator;
    }
}
